
import http from "../utils/request"
import qs from 'qs'

/*import employee from "./quote/employee"
import admin from "./quote/admin";
import dept from "./quote/dept";
import elicon from "./quote/elicon";
import login from "./quote/login";
import menu from "./quote/menu";
import role from "./quote/role";
import user from "./quote/user";

console.log(employee)
export default {
  employee,
  admin,
  dept,
  elicon,
  menu,
  role,
  user,
  login,
}*/


//qs的作用是将data参数转换为username=admin&password=123456这种格式
//请求首页数据
export const getData = () =>{
  //返回一个promise对象
  return http.get('/home/getData');
}

export const getMenuTest = (data) =>{
  return http.get("http://localhost:8080/menu/listMenu",data);
}

/*---------------------------------------------------管理员信息操作-------------------------------------------------------------------*/
//获取管理员列表
export const listAdmin = (params) =>{
  return http.post('/admin/listAdmin',qs.stringify(params));
}
//只修改本身
export const updateByIdAdmin = (data) =>{
  return http.post('/admin/updateByIdAdmin',qs.stringify(data));
}
//添加修改管理员
export const saveOrUpdateAdmin = (data) =>{
  return http.post('/admin/saveOrUpdateAdmin',qs.stringify(data));
}
//获取一个管理员，包括他的角色
export const editRoleByIdAdmin = (data) =>{
  return http.post('/admin/editRoleByIdAdmin',qs.stringify(data));
}
//获取管理员
export const editAdmin = (data) =>{
  return http.get('/admin/editAdmin/'+data.id);
}
//删除管理员
export const delAdmin = (data) =>{
  return http.post('/admin/delAdmin',qs.stringify(data));
}
//给管理员分配角色
export const addAdminRole = (data) =>{
  return http.post('/admin/addAdminRole',qs.stringify(data));
}
//上传头像
export const uploadAvatar = (data) =>{
  return http.post('/admin/uploadAvatar',qs.stringify(data));
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------员工信息操作-------------------------------------------------------------------*/

//请求员工数据
export const listEmp = (params) =>{
  //返回一个promise对象
  //console.log(qs.stringify(params))
  return http.post('/employee/listEmp',qs.stringify(params));
}
//添加和修改
export const saveOrUpdateEmp = (data) =>{
  return http.post('/employee/saveOrUpdateEmp',qs.stringify(data));
}
//删除
export const delEmp = (data)=>{
  return http.post("/employee/delEmp",qs.stringify(data));
}
//根据员工id获取角色
export const editRoleByIdEmp = (data) => {
  return http.post("/employee/editRoleByIdEmp", qs.stringify(data));
}

/*----------------------------------------------------------------------------------------------------------------------*/

/*---------------------------------------------------角色信息操作-------------------------------------------------------------------*/
//请求角色数据
export const listRole = (params) =>{
  //返回一个promise对象
  //console.log(qs.stringify(params))
  return http.post('/role/listRole',qs.stringify(params));
}
//请求角色数据分页
export const listPageRole = (data) =>{
  return http.post('/role/listPageRole',qs.stringify(data));
}
//添加或修改角色
export const saveOrUpdateRole = (data) =>{
  return http.post('/role/saveOrUpdateRole',qs.stringify(data));
}
//根据角色id查找部门和菜单
export const editRoleAndDeptIdAndMenuId = (data) =>{
  return http.post('/role/editRoleAndDeptIdAndMenuId',qs.stringify(data));
}
//只修改角色表的数据
export const updateById = (data) =>{
  return http.post('/role/updateById',qs.stringify(data));
}
//删除
export const delRole = (data) =>{
  return http('/role/delRole/'+data.roleId);
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------部门信息操作-------------------------------------------------------------------*/
//请求部门数据
export const listDeptTree = (params) =>{
  return http.post('/dept/listDeptTree',qs.stringify(params));
}
//条件请求部门数据
export const listQueryDeptTree = (data) =>{
  return http.post('/dept/listQueryDeptTree',qs.stringify(data));
}
//添加修改
export const saveOrUpdateDept = (data) =>{
  return http.post('/dept/saveOrUpdateDept',qs.stringify(data));
}
//查找一条
export const editDept = (data) =>{
  return http.post('/dept/editDept/'+data.deptId);
}
//删除
export const delDept = (data) =>{
  return http.get('/dept/delDept/'+data.deptId);
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------菜单信息操作-------------------------------------------------------------------*/
//请求递归后的菜单数据
export const listMenuTree = (params) =>{
  //console.log(qs.stringify(params))
  return http.post('/menu/listMenuTree',qs.stringify(params));
}
//带条件的递归查询
export const listQueryMenuTree = (params) =>{
  return http.post('/menu/listQueryMenuTree',qs.stringify(params));
}
//添加或修改
export const saveOrUpdateMenu = (data) =>{
  return http.post('/menu/saveOrUpdateMenu',qs.stringify(data));
}
//根据id查找一条
export const editMenu = (data) =>{
  return http.post('/menu/editMenu/'+data.menuId);
}
//根据id删除一条
export const delMenu = (data) =>{
  return http.get('/menu/delMenu/'+data.menuId);
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------el图标信息操作-------------------------------------------------------------------*/
//请求图标数据
export const listElicon = (data) =>{
  return http.post('/elicon/listElicon',qs.stringify(data));
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------业主用户信息操作-------------------------------------------------------------------*/
//请求用户数据
export const listQueryUser = (params) =>{
  return http.post('/user/listQueryUser',qs.stringify(params));
}
//添加或修改
export const saveOrUpdateUser = (data) =>{
  return http.post('/user/saveOrUpdateUser',qs.stringify(data));
}
//删除
export const delUser = (data) =>{
  return http.get('/user/delUser/'+data.id);
}
//批量删除
export const delUsers = (data) =>{
  return http.post('/user/delUsers',qs.stringify(data));
}
//查找一条
export const editUser = (data) =>{
  return http.post('/user/editUser/'+data.id);
}
//导出
export const downloadUsers = (data) =>{
  return http.post('/user/downloadUsers/');
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------系统地址信息操作------------------------------------------------------------------*/
//请求系统地址数据
export const listPageSystemAddress = (params) =>{
  return http.post('/systemAddress/listPageSystemAddress',qs.stringify(params));
}
//添加或修改
export const saveOrUpdateSystemAddress = (data) =>{
  return http.post('/systemAddress/saveOrUpdateSystemAddress',qs.stringify(data));
}
//根据id查询一条
export const editSystemAddress = (data) =>{
  return http.get('/systemAddress/editSystemAddress/'+data.id);
}
//删除
export const delSystemAddress = (data) =>{
  return http.get('/systemAddress/delSystemAddress/'+data.id);
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------文件地址信息操作------------------------------------------------------------------*/
//请求文件地址数据
export const listPageFileAddress = (params) =>{
  return http.post('/fileAddress/listPageFileAddress',qs.stringify(params));
}
//添加或修改
export const saveOrUpdateFileAddress = (data) =>{
  return http.post('/fileAddress/saveOrUpdateFileAddress',qs.stringify(data));
}
//根据id查询一条
export const editFileAddress = (data) =>{
  return http.get('/fileAddress/editFileAddress/'+data.id);
}
//删除
export const delFileAddress = (data) =>{
  return http.get('/fileAddress/delFileAddress/'+data.id);
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------文件上传记录信息操作------------------------------------------------------------------*/
//请求文件上传记录数据
export const listPageUploadFile = (params) =>{
  return http.post('/uploadFile/listPageUploadFile',qs.stringify(params));
}
//删除
export const delUploadFile = (data) =>{
  return http.get('/uploadFile/delUploadFile/'+data.id);
}
//批量删除
export const delUploadFiles = (data) =>{
  return http.post('/uploadFile/delUploadFiles',qs.stringify(data));
}
/*----------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------广告图片管理操作------------------------------------------------------------------*/
//请求文件上传记录数据
export const listPageAdvertisement = (params) =>{
  return http.post('/advertisement/listPageAdvertisement',qs.stringify(params));
}
//上传图片
export const uploadImage = (data) =>{
  return http.post('/advertisement/uploadImage',qs.stringify(data));
}
//修改
export const updateAdvertiseent = (data) =>{
  return http.post('/advertisement/updateAdvertiseent',qs.stringify(data));
}
//删除
export const delAdvertisement = (data) =>{
  return http.get('/advertisement/delAdvertisement/'+data.id);
}
//批量删除
export const delAdvertisements = (data) =>{
  return http.post('/advertisement/delAdvertisements',qs.stringify(data));
}
/*----------------------------------------------------------------------------------------------------------------------*/

export const login = (data) =>{
  //const json=JSON.stringify(data);
  console.log(qs.stringify(data));
  return http.post("/login/admin/login",qs.stringify(data));
}






